﻿@{
    ViewBag.Title = "MemloanIng";
    Layout = "~/Views/Shared/MyAccount.cshtml";
}

    <link href="~/Content/BootstrapSouce/css/bootstrap.min.css" rel="stylesheet" />
    <script src="~/Content/BootstrapSouce/js/jquery.js"></script>
    <script src="~/Content/BootstrapSouce/js/bootstrap.min.js"></script>
    <script src="~/Scripts/Command.js"></script>
    <script>
    $(document).ready(function () {
        var shou = 1;
        pagefun(shou);
    })
    function cha() {
        var shou = 1;
        pagefun(shou);
    }
    function pagefun(j) {
        var MinTime = $("#MinTime").val();
        var MaxTime = $("#MaxTime").val();
        var Title = $("#Text1").val();
        if (MinTime=="") {
            MinTime = "1700-1-1";
        }
        if (MaxTime=="") {
            MaxTime = "1700-1-1";
        }
        $("#ttable").empty();
        $.ajax({
            type: "post", //访问WebService使用Post方式请求
            //contentType: "application/json;charset=utf-8",
            url: "/Memloan/MemloanIngDo",
            dataType: 'json',
            beforeSend: function (x) { x.setRequestHeader("Content-Type", "application/json; charset=utf-8"); },
            data: '{"pageSize":" 5","pageIndex":"' + j + '","Title":"' + Title + '","MinTime":"' + MinTime + '","MaxTime":"' + MaxTime + '","State":"5","Userid":"0" }',
            success: function (response) { //回调函数，result，返回值
                var tr = new Array();
                tr.push("<tr><th style='text-align:center'>编号</th><th style='text-align:center'>借款标题</th><th style='text-align:center'>借款金额</th><th style='text-align:center'>借款期限</th><th style='text-align:center'>还款方式</th><th style='text-align:center'>借款人</th><th style='text-align:center'>标的状态</th><th style='text-align:center'>发布借款时间</th></tr>");
                //var item = JSON.parse(response.d);
                //动态加列表的行数据

                for (var i = 0; i < response.Data.length; i++) {
                    tr.push("<tr style='text-align:center'><td>" + response.Data[i].MemLoanId + "</td><td>" + response.Data[i].Title + "</td><td>" + response.Data[i].LoanMoney + "</td><td>" + response.Data[i].LoanTerm + "</td><td>" + response.Data[i].RepaymentModeId + "</td><td>" + response.Data[i].UserName + "</td><td style=' background-color:#4ed5bc;color:#ffffff'>" + response.Data[i].state + "</td><td>" + ChangeDateFormat(response.Data[i].LaunchLoanTime) + "</td></tr>");
                }
                $("#ttable").append(tr.join(""));
                //动态加翻页
                $("#fen").empty();
                var a0 = '<a href="#" style="width:45px; margin-left:30px; float:left; display:block; height:20px; background-color:#1341f5;color:#ffffff;border-radius:5px;" onclick="pagefun(1)">首页</a> &nbsp;&nbsp;&nbsp;';
                var a1 = '<a href="#" style="width:45px; margin-left:30px; float:left; display:block; height:20px; background-color:#1341f5;color:#ffffff;border-radius:5px;" onclick="pagefun(' + (j - 1) + ')">上一页</a> &nbsp;&nbsp;&nbsp;';
                if (j <= 1) {
                    var a0 = '<span style="width:45px; margin-left:30px;  float:left;display:block;  height:20px; background-color:#787474;color:#ffffff;border-radius:5px;">首页</span> &nbsp;&nbsp;&nbsp;';
                    var a1 = '<span style="width:45px; margin-left:30px; float:left; display:block; height:20px; background-color:#787474;color:#ffffff;border-radius:5px;">上一页</span> &nbsp;&nbsp;&nbsp;';
                }
                var a2 = '<a href="#" style="width:45px; margin-left:30px; float:left; display:block; height:20px; background-color:#1341f5;color:#ffffff;border-radius:5px;" onclick="pagefun(' + (j + 1) + ')">下一页</a> &nbsp;&nbsp;&nbsp;';
                var a3 = '<a href="#" style="width:45px; margin-left:30px; float:left; display:block; height:20px; background-color:#1341f5;color:#ffffff;border-radius:5px;" onclick="pagefun(' + (response.IndexCount) + ')">尾页</a> &nbsp;&nbsp;&nbsp;';
                var a5 = '<span style="color:#1015f5;font-weight:bold;">当前为第&nbsp;&nbsp;' + response.PageIndex + '&nbsp;&nbsp;页</span>';
                if (j >= response.IndexCount) {
                    var a2 = '<span style="width:45px; margin-left:30px; float:left; display:block; height:20px; background-color:#787474;color:#ffffff;border-radius:5px;">下一页</span> &nbsp;&nbsp;&nbsp;';
                    var a3 = '<span style="width:45px; margin-left:30px; float:left; display:block; height:20px; background-color:#787474;color:#ffffff;border-radius:5px;">尾页</span> &nbsp;&nbsp;&nbsp;';
                    var a5 = '<span style="color:#1015f5;font-weight:bold;">当前为第&nbsp;&nbsp;' + response.PageIndex + '&nbsp;&nbsp;页</span>';
                }
                $("#fen").append(a0);
                $("#fen").append(a1);
                $("#fen").append(a2);
                $("#fen").append(a3);
                $("#fen").append(a5);
            }
        });
    }
    </script>
    <style>
        #div {
            margin: 0;
            padding: 0;
            width: 100%;
            height: 100%;
        }
    </style>
    <div id="div">
        <h2 style="font-weight:bold;text-align:center;">成功的借款</h2><br />

        <input id="MinTime" type="date" style="margin-left:370px;" />&nbsp;&nbsp;<input id="MaxTime" type="date" />&nbsp;&nbsp;
        <input id="Text1" type="text" placeholder="请输入标题关键字" />&nbsp;&nbsp;<input id="Button1" class="btn-primary" style="width:40px; border-radius:5px;" type="button" value="查询" onclick="cha()" /><br /><br />
        <table class="table table-striped table-hover table-bordered table-responsive " style="cursor:pointer" id="ttable"></table>
        <div id="fen" style="text-align:center; margin-left:300px;">
        </div>
    </div>


